package com.Hearthstone;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Game {
    public static void main(String[] args) {
        //先手角色随从

        List<Summon> summonList1 = new ArrayList<>();

        Player player1 = new Player(summonList1);


        //后手角色随从
        List<Summon> summonList2 = new ArrayList<>();

        Player player2 = new Player(summonList2);


        //当前操作角色
        Player nowPlayer = player1;
        Player otherPlayer = player2;


        Scanner sc = new Scanner(System.in);
        //操作次数
        int num = sc.nextInt();
        sc.nextLine();
        for (int i = 0; i < num; i++) {

            String operation = sc.nextLine();
            String[] ope = operation.split("");
            if(ope[0].equals("summon")){
                Summon summon = new Summon(Integer.parseInt(ope[2]),Integer.parseInt(ope[3]));
                summonList1.add(Integer.parseInt(ope[1]),summon);
            }
            if(ope[0].equals("end")){
                nowPlayer = player2;
                otherPlayer = player1;
            }
            if(ope[0].equals("attack")){
                int nowPosition = Integer.parseInt(ope[1]) - 1;
                int otherPosition = Integer.parseInt(ope[2]) - 1;
                if(otherPosition == -1){
                    otherPlayer.health -= nowPlayer.summonList.get(nowPosition).attack;
                }

                int health = otherPlayer.summonList.get(otherPosition).health - nowPlayer.summonList.get(nowPosition).attack;
                if(health <= 0){
                    otherPlayer.summonList.remove(otherPosition);
                }
            }
        }
//后手玩家无随从，先手获胜 输出1
        if(summonList2.size() == 0){
            System.out.println(1);
        }
        else if(summonList1.size() == 0){
            System.out.println(-1);
        }
        else {
            System.out.println(0);
        }
        int health1 = 0;

        int health2 = 0;
        System.out.println(player1.health);
        if(player1.summonList.size() != 0){
            health1 = player1.summonList.get(0).health;
        }

        System.out.println(player1.summonList.size() + " " + health1);

        System.out.println(player2.health);

        if(player2.summonList.size() != 0){
            health2 = player1.summonList.get(0).health;
        }

        System.out.println(player2.summonList.size() + " " + health2);




    }
}
